package com.lcf.system.controller;


import com.lcf.framework.annotation.PermissionCheck;
import com.lcf.framework.vo.PageVO;
import com.lcf.system.dto.dict.SysDictTypeDTO;
import com.lcf.system.query.dict.SysDictTypePageQuery;
import com.lcf.system.query.dict.SysDictTypeQuery;
import com.lcf.system.service.SysDictTypeService;
import com.lcf.system.vo.dict.SysDictTypeDetailVO;
import com.lcf.system.vo.dict.SysDictTypeVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.lcf.framework.enums.PermissionEnum.*;

/**
 * 字典类型(SysDictType)表控制层
 *
 * @author lcf
 * @since 2025-03-16 22:04:24
 */
@Tag(name = "字典类型")
@RestController
@RequestMapping("sysDictType")
public class SysDictTypeController {
    @Resource
    private SysDictTypeService sysDictTypeService;

    /**
     * 新增字典类型
     */
    @Operation(summary = "新增字典类型")
    @PermissionCheck(SYS_DICT_TYPE_ADD)
    @PostMapping
    public void add(@RequestBody @Validated SysDictTypeDTO dto) {
        sysDictTypeService.add(dto);
    }

    /**
     * 修改字典类型
     */
    @Operation(summary = "修改字典类型")
    @PermissionCheck(SYS_DICT_TYPE_EDIT)
    @PatchMapping("{dictTypeId}")
    public void edit(@PathVariable @Schema(description = "字典类型ID") long dictTypeId,
                     @RequestBody @Validated SysDictTypeDTO dto) {
        sysDictTypeService.edit(dictTypeId, dto);
    }

    /**
     * 删除字典类型
     */
    @Operation(summary = "删除字典类型")
    @PermissionCheck(SYS_DICT_TYPE_DEL)
    @DeleteMapping("{dictTypeId}")
    public void delete(@PathVariable @Schema(description = "字典类型ID") long dictTypeId) {
        sysDictTypeService.delete(dictTypeId);
    }

    /**
     * 获取字典类型
     */
    @Operation(summary = "获取字典类型")
    @PermissionCheck(SYS_DICT_TYPE_DETAIL)
    @GetMapping("{dictTypeId}")
    public SysDictTypeDetailVO get(@PathVariable @Schema(description = "字典类型ID") long dictTypeId) {
        return sysDictTypeService.get(dictTypeId);
    }

    /**
     * 获取字典类型列表
     */
    @Operation(summary = "获取字典类型列表")
    @PermissionCheck(SYS_DICT_TYPE_LIST)
    @GetMapping("list")
    public List<SysDictTypeVO> list(SysDictTypeQuery query) {
        return sysDictTypeService.list(query);
    }

    /**
     * 获取字典类型分页列表
     */
    @Operation(summary = "获取字典类型分页列表")
    @PermissionCheck(SYS_DICT_TYPE_PAGE)
    @GetMapping("page")
    public PageVO<SysDictTypeVO> page(SysDictTypePageQuery query) {
        return sysDictTypeService.page(query);
    }
}

